<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamicButtons="tableButtons"
      :dynamicComponents="tableComponents"
      :dynamicTableCols="tableCols"
      :dynamic-api-config="apiConfig"
      :dynamicFormFields="formField"
      :dynamicIsShowSelect="false"
      :dynamicIsInitTable="true"
      :dynamicIsColumnDrop="true"
    >
      <div slot="isEnable"></div>
      <template slot="controlBtn" slot-scope="scope">
        <el-button type="primary" size="mini" class="el-icon-edit" @click="edit(scope.row.index)">编辑</el-button>
      </template>
    </one-table-template>
    <edit
      :dynamicEditRowData="editRowData"
      :popupsVisible="editPopupsVisible"
      :key="editPopupsKey"
      :popupsState="editPopupsState"
      @close="close"
    />
  </div>
</template>

<script>
import OneTableTemplate from "@/components/wms/templates/oneTable";
import { wmsApis } from "@/api/wms/baseData/api";
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import request from "@/utils/request";
export default {
  components: {
    OneTableTemplate,
    Edit: () => import("./edit")
  },
  mixins: [oneTableWithViewTemplateMixins],
  data() {
    return {
      apiConfig: wmsApis.querySuppUser,
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          name: "search",
          position: "right",
          clickEvent: () => this.queryTable(1),
          text: this.$t("sys.button.query") /*查询*/
        },
        {
          compKey: "btnKey4",
          type: "",
          size: "small",
          name: "reset",
          position: "right",
          clickEvent: () => this.reset(),
          text: this.$t("sys.button.reset") /*重置*/
        },
        {
          compKey: "btnKey3",
          type: "add",
          size: "small",
          name: "add",
          position: "left",
          clickEvent: () => this.add(),
          text: "新增" /*导出*/
        }
      ],
      tableComponents: [
        {
          compKey: "compKey1",
          labelName: "用户编号",
          codeField: "USER_NAME",
          component: () => import("@/components/wms/commonInput"),
          type: "dropdownList",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "用户名称",
          codeField: "EMP_NAME",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey3",
          labelName: "状态",
          codeField: "IS_ENABLE",
          component: () => import("@/components/wms/isEnable/isEnableOne"),
          type: "dropdownList",
          isMust: true
        }
      ],
      tableCols: this.getCols(),
      //表单查询数据
      formField: {
        USER_NAME: "",
        EMP_NAME: "",
        IS_ENABLE: ""
      }
    };
  },
  methods: {
    getCols() {
      var cols = [
        {
          prop: "controlBtn",
          label: "操作", //"操作"
          codeField: "controlBtn",
          width: 120,
          align: "center",
          isSlot: true
        }
      ];
      cols = cols.concat([
        {
          prop: "WAREHOUSE_USER_ID",
          label: "用户编号",
          align: "center"
        },
        {
          prop: "EMP_NAME",
          label: "用户名称",
          align: "center"
        },
        {
          prop: "PARTNER_SHORT_NAME",
          label: "供应商简称",
          align: "center"
        },
        {
          prop: "IS_ENABLE_STR",
          label: "状态",
          align: "center"
        }
      ]);
      return cols;
    }
  }
};
</script>
